// server/src/routes/categories.ts
import { Router } from 'express'
import { 
  getCategories, 
  getCategory, 
  createCategory, 
  updateCategory, 
  deleteCategory 
} from '../controllers/categoryController'
import { authenticateToken, requireAdmin } from '../middleware/auth'

const router = Router()

// 公开路由
router.get('/', getCategories)
router.get('/:id', getCategory)

// 需要管理员权限的路由
router.post('/', authenticateToken, requireAdmin, createCategory)
router.put('/:id', authenticateToken, requireAdmin, updateCategory)
router.delete('/:id', authenticateToken, requireAdmin, deleteCategory)

export default router